package com.andova.component.config;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by Administrator on 2018-08-27.
 *
 * @author kzaxil
 * @since 0.0.2
 */
public class ValueBean extends Value {
    /**
     * 节点的备选值
     */
    public Set<Value> alternative;

    public ValueBean(String value) {
        this(value, null, null);
    }

    public ValueBean(String value, String valueAlias) {
        this(value, valueAlias, null);
    }

    public ValueBean(String value, Set<Value> alternative) {
        this(value, null, alternative);
    }

    public ValueBean(String value, String valueAlias, Set<Value> alternative) {
        super(value, valueAlias);
        this.alternative = alternative;
    }

    public Set<String> values() {
        if (alternative == null) return null;
        Set<String> values = new HashSet<>(alternative.size());
        for (Value value : alternative) {
            values.add(value.value);
        }
        return values;
    }

    public Set<String> valueAliases() {
        if (alternative == null) return null;
        Set<String> aliases = new HashSet<>(alternative.size());
        for (Value value : alternative) {
            aliases.add(value.valueAlias);
        }
        return aliases;
    }
}
